package com.mjduan.project.goodExample;

/**
 * Hans 2017-09-16 20:23
 */
public class YellowTrafficLightState extends State {
    private TrafficLight trafficLight;

    public YellowTrafficLightState(TrafficLight trafficLight) {
        this.trafficLight = trafficLight;
    }

    @Override
    public void handleRequest() {
        System.out.println(getClass().getName() + ":Turning traffic yellow-light to red");
        trafficLight.setState(trafficLight.getRedState());
    }

    @Override
    public String toString() {
        return "Traffic light is yellow";
    }
}
